var value = 2;




Function.prototype.myBind = function (target, ...bindArgs){
  var self = this;
 
  var fNoop = function(){}
  let fbound =  function(...args){
    self.apply(this instanceof self ? this : target, bindArgs.concat(args));
  }
  fNoop.prototype = this.prototype;
  fbound.prototype = new fNoop()
  return fbound;
}

var foo = {
  value: 1
};

function bar(name, age) {
  this.habit = 'shopping';
  console.log(this.value);
  console.log(name);
  console.log(age);
}

bar.prototype.friend = 'kevin';

var bindFoo = bar.myBind(foo, 'daisy');

var obj = new bindFoo('18');

console.log('ins',obj instanceof bar);

bindFoo.prototype.friend = 'a'
console.log('origin',  new bar().friend)
